package com.haizhi.crm.api.controller.sys.configure;

import com.haizhi.crm.biz.service.UserModuleQueryService;
import com.haizhi.crm.common.model.Response;
import com.haizhi.crm.sys.configure.model.UserModuleQo;
import com.haizhi.crm.sys.configure.model.UserModuleSettingQo;
import com.haizhi.crm.sys.configure.service.UserModuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * Created by yangyijun on 2018/07/03.
 */
@Api(description = "[系统-自定义模块]-增删改查" )
@RestController
@RequestMapping("/userModel" )
public class UserModelController {

    @Resource
    private UserModuleService userModuleService;
    @Autowired
    private UserModuleQueryService userModuleQueryService;


    @ApiOperation(value = "查询所有可配置的模块列表" )
    @GetMapping("/list" )
    public Response list() {
        return userModuleService.list();
    }

    @ApiOperation(value = "添加|取消用户自定义模块" )
    @PostMapping("/saveUserModule" )
    public Response saveUserModule(@RequestBody @Valid UserModuleQo userModuleQo) {
        return userModuleService.saveUserModule(userModuleQo);
    }
//
//    @ApiOperation(value = "查询模块可配置的属性")
//    @GetMapping(path = "/findModuleSettings")
//    public Response findModuleSettings(@RequestParam Long moduleId) {
//        return userModuleService.findModuleSettings(moduleId);
//    }

    @ApiOperation(value = "保存|修改用户模块属性配置" )
    @PostMapping(path = "/saveUserModuleSettings" )
    public Response saveUserModuleSettings(@RequestBody @Valid UserModuleSettingQo userModuleSettingQo) {
        return userModuleService.saveUserModuleSettings(userModuleSettingQo);
    }

    @ApiOperation(value = "查询用户模块属性配置" )
    @GetMapping(path = "/findUserModuleSettings" )
    public Response findUserModuleSettings(@RequestParam Long moduleId) {
        return userModuleService.findUserModuleSettings(moduleId);
    }

    @ApiOperation(value = "查询用户模块列表及数据" )
    @GetMapping("/findUserModules" )
    public Response findUserModules() {
        return userModuleQueryService.findUserModules();
    }
}
